﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Engine.Dtd.Schema;

namespace Engine.Sgml.Matching {
    internal sealed class CaptureCollection : Collection<Capture> {
        internal void Add(SElement element) {
            Guard.ArgumentNotNull(element, "element");
            base.Add(new Capture(element));
            }

        internal void Add(IModelGroupsNode model, SElement element) {
            Guard.ArgumentNotNull(model, "model");
            Guard.ArgumentNotNull(element, "element");
            base.Add(new Capture(model, element));
            }

        internal void Add(IModelGroupsNode model) {
            Guard.ArgumentNotNull(model, "model");
            base.Add(new Capture(model));
            }

        internal void Add(Match match, bool success) {
            Guard.ArgumentNotNull(match, "match");
            base.Add(new Capture(match, success));
            }

        internal Capture? FindBy(IModelGroupsNode model) {
            for (int i = 0; i < Count; i++) {
                if (base[i].Entity.Model == model)
                    return base[i];
                }
            return null;
            }

        internal bool Contains(IModelGroupsNode model) {
            for (int i = 0; i < Count; i++) {
                if (base[i].Entity.Model == model)
                    return true;
                }
            return false;
            }
        }
    }
